Ext.define("marketing.salesGroup.view",{
	extend : 'Ext.window.Window',
	config : {
		salesGroupId : ''
	},
	initComponent : function() {
		var salesGroupId = this.salesGroupId;
		var fromPanel =  Ext.create("Ext.form.Panel", {
			region : 'north',
			collapsible : false, 
			autoScroll : false, 
			defaultType : 'textfield',
			items : [{
				xtype : 'displayfield',
				fieldLabel : '所属项目',
				name:'projectCN'
			    },{
			    	xtype : 'displayfield',
					fieldLabel : '销售组名称',
					name:'name'
			    },{
			    	xtype : 'displayfield',
					fieldLabel : '销售组状态',
					name:'statusCN'
			    },{
			    	xtype : 'displayfield',
					fieldLabel : '排序编号',
					name:'sort'
			    }]
		});
		
		fromPanel.getForm().load({
			url:jypath+'/marketing/salesGroup/responseSalesGroup',
			params:{'id':salesGroupId},
			success:function(form, action){},   
			failure: function(form, action) {
		        Ext.Msg.alert("加载失败", action.result.errorMessage);
		    }

		});
		
		
	    var gridStore = Ext.create('Ext.data.Store', {
	        fields: ["userCN","statusCN"],
	        pageSize: 10, 
	        remoteSort: false,
	        proxy: {
	            type: 'ajax',
	            url: jypath+'/marketing/salesGroupUser/findSalesGroupUserDto?salesGroupId='+salesGroupId,
	            reader: {   
	                type: 'json', 
	                root: 'rows',  
	                totalProperty: 'total' 
	            }
	        },
	        autoLoad: true  // 即时加载数据
	    });
		
		
		var gridPanel = Ext.create('Ext.grid.Panel', {
			region : 'center',
	        columnLines: true,
	        store: gridStore,
	        title: '销售组列表',
	        viewConfig: {
	            stripeRows: true
	        },
	        columns: [{
	            text: '经纪人',
	            dataIndex: 'userCN',
	        },{
	            text     : '组员状态', 
	            dataIndex: 'statusCN'
	        }],
	        dockedItems: [{  
	            xtype: 'pagingtoolbar',  
	            store: gridStore,   // GridPanel中使用的数据  
	            dock: 'bottom',  
	            displayInfo: true,  
	            emptyMsg:"没有数据",  
	            displayMsg:"显示从{0}条数据到{1}条数据，共{2}条数据"
	        }
	        ]
	    });
		
		
		var defaultConfig = {
				frame:true,
				title : '销售组详情',
				width: 500,
			    height: 350,
			 
		        modal: true,
				layout : 'border',
				items:[fromPanel,gridPanel]
		};
		Ext.apply(this,defaultConfig);
		this.callParent();
	}
});